﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:ReflectionStudio.Controls"
    >
    
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/ReflectionStudio.Controls;component/Resources/Controls/FrameButtons.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    
    <!--OFFICE STYLE WINDOW-->
    <Style x:Key="{x:Type local:OfficeWindow}" TargetType="{x:Type local:OfficeWindow}">
        <Setter Property="AllowsTransparency" Value="True"/>
        <Setter Property="WindowStyle" Value="None"/>
        <Setter Property="ResizeMode" Value="CanResizeWithGrip"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:OfficeWindow}">
                    <AdornerDecorator>
                        <Border x:Name="PART_WindowBorder" CornerRadius="4"  Focusable="False"
                                Background="{DynamicResource WindowBackgroundBrush}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>

                                <Border Background="{DynamicResource WindowBackgroundBrush}"
                                        CornerRadius="5"
                                        VerticalAlignment="Stretch"
                                        BorderThickness="1"
                                        BorderBrush="Black"></Border>
                                
                                <!-- Drag container for the titlebar -->
                                <Control x:Name="PART_Titlebar" Grid.Row="0" Background="Transparent" Height="26"
                                        VerticalAlignment="Top" HorizontalAlignment="Stretch" Focusable="False"
                                        Panel.ZIndex="100" Margin="180,0,65,0">
                                        <Control.Template>
                                        <ControlTemplate>
                                            <Grid>
                                                <TextBlock
                                            Text="{Binding Title, RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}}}" 
                                            HorizontalAlignment="Stretch" VerticalAlignment="Center" 
                                            Foreground="{DynamicResource WindowForegroundBrush}" Focusable="False" Margin="4"
                                            Visibility="Hidden"
                                            />
                                            </Grid>
                                            </ControlTemplate>
                                        </Control.Template>
                                </Control>

                                <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,2,5,0" VerticalAlignment="top"
                                            HorizontalAlignment="Right" Panel.ZIndex="100">
                                    <Button Width="18" Height="18" Style="{StaticResource minimizeButton}"
                                            x:Name="PART_Minimize" SnapsToDevicePixels="True" IsTabStop="False" Focusable="False">
                                    </Button>
                                    <Button Width="18" Height="18" Margin="2,0,0,0" IsTabStop="False" Focusable="False"
                                            Style="{StaticResource maximizeButton}" x:Name="PART_Maximize">
                                    </Button>
                                    <Button Width="18" Height="18" Margin="2,0,0,0" IsTabStop="False" Focusable="False"
                                            Style="{StaticResource closeButton}" x:Name="PART_Close">
                                    </Button>
                                </StackPanel>

                                <!-- Window content -->
                                <ContentPresenter Grid.Row="0" Margin="4"/>

                                <!-- Resize helpers -->
                                <Rectangle Grid.Row="0" Grid.Column="0" Fill="Transparent" HorizontalAlignment="Stretch" Focusable="False"
                                           VerticalAlignment="Top" Height="10" x:Name="PART_ResizeTop" Cursor="SizeNS"/>

                                <Rectangle Grid.Row="1" Grid.Column="0" Fill="Transparent" HorizontalAlignment="Stretch" Focusable="False"
                                           VerticalAlignment="Bottom" Height="10" x:Name="PART_ResizeBottom" Cursor="SizeNS"/>

                                <Rectangle Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Fill="Transparent" HorizontalAlignment="Left"
                                           VerticalAlignment="Stretch" Width="10" x:Name="PART_ResizeLeft" Cursor="SizeWE" Focusable="False"/>

                                <Rectangle Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Fill="Transparent" HorizontalAlignment="Right"
                                           VerticalAlignment="Stretch" Width="10" x:Name="PART_ResizeRight" Cursor="SizeWE" Focusable="False"/>

                                <ResizeGrip Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" 
                                           VerticalAlignment="Bottom" Width="17" Height="17" Focusable="False" Margin="0,0,2,2"
                                           x:Name="PART_ResizeGrip" Cursor="SizeNWSE"/>
                            </Grid>
                        </Border>
                    </AdornerDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="WindowState" Value="Maximized">
                            <Setter Property="CornerRadius" TargetName="PART_WindowBorder" Value="0"/>
                        </Trigger>
                        <Trigger Property="ResizeMode" Value="CanMinimize">
                            <Setter TargetName="PART_Maximize" Property="IsEnabled" Value="False"/>
                        </Trigger>
                        <Trigger Property="ResizeMode" Value="CanMinimize">
                            <Setter TargetName="PART_Maximize" Property="IsEnabled" Value="False"/>
                        </Trigger>
                        <Trigger Property="ResizeMode" Value="NoResize">
                            <Setter TargetName="PART_Maximize" Property="Visibility" Value="Collapsed"/>
                            <Setter TargetName="PART_Minimize" Property="Visibility" Value="Collapsed"/>
                            <Setter TargetName="PART_ResizeLeft" Property="Visibility" Value="Collapsed"/>
                            <Setter TargetName="PART_ResizeBottom" Property="Visibility" Value="Collapsed"/>
                            <Setter TargetName="PART_ResizeTop" Property="Visibility" Value="Collapsed"/>
                            <Setter TargetName="PART_ResizeRight" Property="Visibility" Value="Collapsed"/>
                            <Setter TargetName="PART_ResizeGrip" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>

    

    